﻿using System;
using System.Collections.Generic;
using System.Text;

namespace PCR.Base
{
    /// <summary>
    /// User role interface, define the 
    /// user's privilege, but current now we won't implement it
    /// </summary>
    public interface IUserRole
    {
        
    }
    
    /// <summary>
    /// User interface, represent a user's information
    /// </summary>
    public interface IUser : IGuidObject
    {
        /// <summary>
        /// Get or set the user's name
        /// </summary>
        string UserName { get; set; }
        
        /// <summary>
        /// Get or set the password, we would encrypt it
        /// </summary>
        string Password { get; set; }
        
        /// <summary>
        /// Get or set the user role
        /// Note : not implement current now
        /// </summary>
        IUserRole Role { get; set; }
    }

    /// <summary>
    /// A simple privilege manager interface,
    /// only support one user and don't support user role
    /// </summary>
    public interface IPrivilegeManager
    {
        /// <summary>
        /// Get the current user
        /// </summary>
        /// <returns>Return the current user interface, 
        /// return null if no user existed</returns>
        IUser GetUser();
        
        /// <summary>
        /// Update the user information
        /// </summary>
        /// <param name="user">The user instance need to update</param>
        /// <returns>true if successfully, false if failed</returns>
        bool UpdateUser(IUser user);

        /// <summary>
        /// Update the user by user name and password
        /// </summary>
        /// <param name="userName">The user name</param>
        /// <param name="password">The user password</param>
        /// <returns>true if successfully, false if failed</returns>
        bool UpdateUser(string userName, string password);

        /// <summary>
        /// Validate the user
        /// </summary>
        /// <param name="userName">User name</param>
        /// <param name="password">User password</param>
        /// <returns>true if user and password are both right,
        /// otherwise return false</returns>
        bool ValidateUser(string userName, string password);
    }

    /// <summary>
    /// Extended Privilege Manager instance, should support
    /// multiply user, user group and user role
    /// </summary>
    public interface IPrivilegeManagerEx : IObjectRepository<IUser>
    {

    }
}
